package com.rc.mutievcharger.dto.ylevcharger.terminal;

import com.rc.evcharger.common.annotation.ByteLength;
import com.rc.evcharger.common.base.yl.BaseYlCommand;
import com.rc.evcharger.common.constant.SocketConstant;
import com.rc.evcharger.common.utils.DataUtil;
import com.rc.evcharger.common.utils.NumberUtil;
import com.rc.evcharger.common.utils.YlDataUtil;

import java.math.BigDecimal;

/**
 * Create by Yang on 2021/4/26
 * (CMD=7)充电桩对后台控制命令应答
 */
public class YlStartCommandResp extends BaseYlCommand {


    @ByteLength(length = 2)
    private String bmsVoltage; //BMS 辅源电压  tartCommandResp(String orderNum 0-12V；1-24V。仅当前充电有效，当前充电完成恢复为充电机系统设置值
    @ByteLength(length = 1)
    private String stopSoc; //SOC停止量
    @ByteLength(length = 1)
    private String gunNum; //充电枪口   编号从 1 开始
    @ByteLength(length = 4)
    private String chargingType; //0:即时充电    1:定时启动充电    2:预约充电
    @ByteLength(length = 4)
    private String pwdStop; //界面充电停止密码
    @ByteLength(length = 4)
    private String chargingPolicy; //充电策略0:充满为止 1:时间控制充电 2:金额控制充电 3:电量控制充电
    @ByteLength(length = 4)
    private String chargingPolicyParm; //充电策略参数 时间单位为 1 秒 金额单位为 0.01 元  电量时单位为 0.01kw
    @ByteLength(length = 8)
    private String taskTime; //预约/定时启动时间  标准时间
    @ByteLength(length = 1)
    private String outTaskTime; //预约超时时间  单位分钟
    @ByteLength(length = 32)
    private String card; //用户卡号/用户识别号   ASCII 码，不够长度填’\0’
    @ByteLength(length = 1)
    private String offCharingFlag; //断网充电标志    0-不允许 1-允许
    @ByteLength(length = 4)
    private String loginoutPower; //离线可充电电量 0.01KW
    @ByteLength(length = 32)
    private String orderNum; //充电流水号


    public YlStartCommandResp(String orderNum, String gunNum) {
        if (gunNum.length() < 2) {
            gunNum = SocketConstant.STR_CON0 + gunNum;
        }
        this.gunNum = gunNum;

        this.bmsVoltage = "00 00";
        this.stopSoc = "00 00";
        this.chargingType = "00 00 00 00";
        this.pwdStop = "57 04 00 00";
        this.chargingPolicy = "00 00 00 00";
        this.chargingPolicyParm = "00 00 00 00";
        this.taskTime = "00 00 00 00 00 00 00 00";
        this.outTaskTime = "00";
        this.card = YlDataUtil.getTerminalIdFrame(orderNum.substring(10));
        this.offCharingFlag = "00"; //0-不允许 1-允许
        loginoutPower = "00 00 00 00";
        this.orderNum = YlDataUtil.getTerminalIdFrame(orderNum);


    }

    public String getGunNum() {
        return gunNum;
    }

    public void setGunNum(String gunNum) {
        this.gunNum = gunNum;
    }

    public String getChargingType() {
        return chargingType;
    }

    public void setChargingType(String chargingType) {
        this.chargingType = chargingType;
    }

    public String getPwdStop() {
        return pwdStop;
    }

    public void setPwdStop(String pwdStop) {
        this.pwdStop = pwdStop;
    }

    public String getChargingPolicy() {
        return chargingPolicy;
    }

    public void setChargingPolicy(String chargingPolicy) {
        this.chargingPolicy = chargingPolicy;
    }

    public String getChargingPolicyParm() {
        return chargingPolicyParm;
    }

    public void setChargingPolicyParm(String chargingPolicyParm) {
        this.chargingPolicyParm = chargingPolicyParm;
    }

    public String getTaskTime() {
        return taskTime;
    }

    public void setTaskTime(String taskTime) {
        this.taskTime = taskTime;
    }

    public String getOutTaskTime() {
        return outTaskTime;
    }

    public void setOutTaskTime(String outTaskTime) {
        this.outTaskTime = outTaskTime;
    }

    public String getCard() {
        return card;
    }

    public void setCard(String card) {
        this.card = card;
    }

    public String getOffCharingFlag() {
        return offCharingFlag;
    }

    public void setOffCharingFlag(String offCharingFlag) {
        this.offCharingFlag = offCharingFlag;
    }

    public String getLoginoutPower() {
        return loginoutPower;
    }

    public void setLoginoutPower(String loginoutPower) {
        this.loginoutPower = loginoutPower;
    }

    public String getOrderNum() {
        return orderNum;
    }

    public void setOrderNum(String orderNum) {
        this.orderNum = orderNum;
    }

    public String getBmsVoltage() {
        return bmsVoltage;
    }

    public void setBmsVoltage(String bmsVoltage) {
        this.bmsVoltage = bmsVoltage;
    }

    public String getStopSoc() {
        return stopSoc;
    }

    public void setStopSoc(String stopSoc) {
        this.stopSoc = stopSoc;
    }

    public static void main(String[] args) {
        BigDecimal bdValue = DataUtil.getBDValue("57 04 00 00", 0, true);
        System.out.println(bdValue);
        NumberUtil.binToTen("111");

    }


}
